﻿Public Structure Track
	Dim name As String
	Dim duration As String
	Dim mbid As String
	Dim url As String
    Dim streamable As String
    Dim album As String
    Dim artist As String
    Dim rank As String
    Dim tags() As Tag
	Dim image() As String

	Public Sub New(ByRef xmlTrack As XElement)
		parseXML(xmlTrack)
	End Sub

	Public Sub parseXML(ByRef xmlTrack As XElement)
		If xmlTrack.HasAttributes() Then
			rank = xmlTrack.FirstAttribute
		End If

		If (xmlTrack.<name>.Count > 0) Then
			name = xmlTrack.<name>.Value
		End If
		If (xmlTrack.<duration>.Count > 0) Then
			duration = xmlTrack.<duration>.Value
		End If
		If (xmlTrack.<mbid>.Count > 0) Then
			mbid = xmlTrack.<mbid>.Value
        End If
        If (xmlTrack.<album>.<title>.Count > 0) Then
            album = xmlTrack.<album>.<title>.Value
        End If
		If (xmlTrack.<url>.Count > 0) Then
			url = xmlTrack.<url>.Value
		End If
		If (xmlTrack.<artist>.Count > 0) Then
            artist = xmlTrack.<artist>.First.Value
        End If
        Dim count As Integer
        count = xmlTrack.<toptags>.Count()
        If (count > 0) Then
            ReDim tags(count - 1)
            For i As Integer = 0 To count - 1
                tags(i) = New Tag(xmlTrack.<toptags>.<tag>(i))
            Next
        End If
	End Sub
End Structure
